/* tslint:disable */
/* eslint-disable */
/*
Humanloop API

The Humanloop API allows you to interact with Humanloop from your product or service.

You can do this through HTTP requests from any language or via our official Python or TypeScript SDK.

To install the official [Python SDK](https://pypi.org/project/humanloop/), run the following command:

```bash
pip install humanloop
```

To install the official [TypeScript SDK](https://www.npmjs.com/package/humanloop), run the following command:

```bash
npm i humanloop
```

---

Guides and further details about key concepts can be found in [our docs](https://docs.humanloop.com/).

The version of the OpenAPI document: 4.0.1


NOTE: This file is auto generated by Konfig (https://konfigthis.com).
*/

import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
import { Configuration } from '../configuration';
// Some imports not used depending on template conditions
// @ts-ignore
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, isBrowser } from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
// @ts-ignore
import { FinetuneConfig } from '../models';
// @ts-ignore
import { FinetuneDataSummary } from '../models';
// @ts-ignore
import { FinetuneRequest } from '../models';
// @ts-ignore
import { FinetuneResponse } from '../models';
// @ts-ignore
import { HTTPValidationError } from '../models';
// @ts-ignore
import { ProviderApiKeys } from '../models';
// @ts-ignore
import { UpdateFinetuneRequest } from '../models';
import { paginate } from "../pagination/paginate";
import type * as buffer from "buffer"
import { requestBeforeHook } from '../requestBeforeHook';
/**
 * FinetunesApi - axios parameter creator
 * @export
 */
export const FinetunesApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Trigger the fine-tuning process for a specific base model and data snapshot.
         * @summary Create
         * @param {string} projectId 
         * @param {FinetuneRequest} finetuneRequest 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        create: async (projectId: string, finetuneRequest: FinetuneRequest, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'projectId' is not null or undefined
            assertParamExists('create', 'projectId', projectId)
            // verify required parameter 'finetuneRequest' is not null or undefined
            assertParamExists('create', 'finetuneRequest', finetuneRequest)
            const localVarPath = `/projects/{project_id}/finetunes`
                .replace(`{${"project_id"}}`, encodeURIComponent(String(projectId !== undefined ? projectId : `-project_id-`)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions: AxiosRequestConfig = { method: 'POST', ...baseOptions, ...options};
            const localVarHeaderParameter = configuration && !isBrowser() ? { "User-Agent": configuration.userAgent } : {} as any;
            const localVarQueryParameter = {} as any;

            // authentication APIKeyHeader required
            await setApiKeyToObject({ object: localVarHeaderParameter, key: "X-API-KEY", keyParamName: "xAPIKEY", configuration })

    
            localVarHeaderParameter['Content-Type'] = 'application/json';


            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            requestBeforeHook({
                requestBody: finetuneRequest,
                queryParameters: localVarQueryParameter,
                requestConfig: localVarRequestOptions,
                path: localVarPath,
                configuration,
                pathTemplate: '/projects/{project_id}/finetunes',
                httpMethod: 'POST'
            });
            localVarRequestOptions.data = serializeDataIfNeeded(finetuneRequest, localVarRequestOptions, configuration)

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Get a list of all fine-tuned models associated to a given project.
         * @summary List 
         * @param {string} projectId 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listAllForProject: async (projectId: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'projectId' is not null or undefined
            assertParamExists('listAllForProject', 'projectId', projectId)
            const localVarPath = `/projects/{project_id}/finetunes`
                .replace(`{${"project_id"}}`, encodeURIComponent(String(projectId !== undefined ? projectId : `-project_id-`)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions: AxiosRequestConfig = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = configuration && !isBrowser() ? { "User-Agent": configuration.userAgent } : {} as any;
            const localVarQueryParameter = {} as any;

            // authentication APIKeyHeader required
            await setApiKeyToObject({ object: localVarHeaderParameter, key: "X-API-KEY", keyParamName: "xAPIKEY", configuration })

    
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            requestBeforeHook({
                queryParameters: localVarQueryParameter,
                requestConfig: localVarRequestOptions,
                path: localVarPath,
                configuration,
                pathTemplate: '/projects/{project_id}/finetunes',
                httpMethod: 'GET'
            });

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Checks data for errors and generates finetune data summary.  Does not actually trigger the finetuning process or persist the data.
         * @summary Summarize
         * @param {string} projectId 
         * @param {FinetuneRequest} finetuneRequest 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        summary: async (projectId: string, finetuneRequest: FinetuneRequest, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'projectId' is not null or undefined
            assertParamExists('summary', 'projectId', projectId)
            // verify required parameter 'finetuneRequest' is not null or undefined
            assertParamExists('summary', 'finetuneRequest', finetuneRequest)
            const localVarPath = `/projects/{project_id}/finetunes/summary`
                .replace(`{${"project_id"}}`, encodeURIComponent(String(projectId !== undefined ? projectId : `-project_id-`)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions: AxiosRequestConfig = { method: 'POST', ...baseOptions, ...options};
            const localVarHeaderParameter = configuration && !isBrowser() ? { "User-Agent": configuration.userAgent } : {} as any;
            const localVarQueryParameter = {} as any;

            // authentication APIKeyHeader required
            await setApiKeyToObject({ object: localVarHeaderParameter, key: "X-API-KEY", keyParamName: "xAPIKEY", configuration })

    
            localVarHeaderParameter['Content-Type'] = 'application/json';


            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            requestBeforeHook({
                requestBody: finetuneRequest,
                queryParameters: localVarQueryParameter,
                requestConfig: localVarRequestOptions,
                path: localVarPath,
                configuration,
                pathTemplate: '/projects/{project_id}/finetunes/summary',
                httpMethod: 'POST'
            });
            localVarRequestOptions.data = serializeDataIfNeeded(finetuneRequest, localVarRequestOptions, configuration)

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Update user-specified attributes of the specified finetuned models.
         * @summary Update
         * @param {string} id 
         * @param {string} projectId 
         * @param {UpdateFinetuneRequest} updateFinetuneRequest 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        update: async (id: string, projectId: string, updateFinetuneRequest: UpdateFinetuneRequest, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('update', 'id', id)
            // verify required parameter 'projectId' is not null or undefined
            assertParamExists('update', 'projectId', projectId)
            // verify required parameter 'updateFinetuneRequest' is not null or undefined
            assertParamExists('update', 'updateFinetuneRequest', updateFinetuneRequest)
            const localVarPath = `/finetunes/{id}`
                .replace(`{${"id"}}`, encodeURIComponent(String(id !== undefined ? id : `-id-`)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions: AxiosRequestConfig = { method: 'PATCH', ...baseOptions, ...options};
            const localVarHeaderParameter = configuration && !isBrowser() ? { "User-Agent": configuration.userAgent } : {} as any;
            const localVarQueryParameter = {} as any;

            // authentication APIKeyHeader required
            await setApiKeyToObject({ object: localVarHeaderParameter, key: "X-API-KEY", keyParamName: "xAPIKEY", configuration })
            if (projectId !== undefined) {
                localVarQueryParameter['project_id'] = projectId;
            }


    
            localVarHeaderParameter['Content-Type'] = 'application/json';


            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            requestBeforeHook({
                requestBody: updateFinetuneRequest,
                queryParameters: localVarQueryParameter,
                requestConfig: localVarRequestOptions,
                path: localVarPath,
                configuration,
                pathTemplate: '/finetunes/{id}',
                httpMethod: 'PATCH'
            });
            localVarRequestOptions.data = serializeDataIfNeeded(updateFinetuneRequest, localVarRequestOptions, configuration)

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
    }
};

/**
 * FinetunesApi - functional programming interface
 * @export
 */
export const FinetunesApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = FinetunesApiAxiosParamCreator(configuration)
    return {
        /**
         * Trigger the fine-tuning process for a specific base model and data snapshot.
         * @summary Create
         * @param {FinetunesApiCreateRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async create(requestParameters: FinetunesApiCreateRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<FinetuneResponse>> {
            const finetuneRequest: FinetuneRequest = {
                name: requestParameters.name,
                dataset_id: requestParameters.dataset_id,
                config: requestParameters.config,
                metadata: requestParameters.metadata,
                provider_api_keys: requestParameters.provider_api_keys
            };
            const localVarAxiosArgs = await localVarAxiosParamCreator.create(requestParameters.projectId, finetuneRequest, options);
            return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
        },
        /**
         * Get a list of all fine-tuned models associated to a given project.
         * @summary List 
         * @param {FinetunesApiListAllForProjectRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listAllForProject(requestParameters: FinetunesApiListAllForProjectRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<FinetuneResponse>>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listAllForProject(requestParameters.projectId, options);
            return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
        },
        /**
         * Checks data for errors and generates finetune data summary.  Does not actually trigger the finetuning process or persist the data.
         * @summary Summarize
         * @param {FinetunesApiSummaryRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async summary(requestParameters: FinetunesApiSummaryRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<FinetuneDataSummary>> {
            const finetuneRequest: FinetuneRequest = {
                name: requestParameters.name,
                dataset_id: requestParameters.dataset_id,
                config: requestParameters.config,
                metadata: requestParameters.metadata,
                provider_api_keys: requestParameters.provider_api_keys
            };
            const localVarAxiosArgs = await localVarAxiosParamCreator.summary(requestParameters.projectId, finetuneRequest, options);
            return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
        },
        /**
         * Update user-specified attributes of the specified finetuned models.
         * @summary Update
         * @param {FinetunesApiUpdateRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async update(requestParameters: FinetunesApiUpdateRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<FinetuneResponse>> {
            const updateFinetuneRequest: UpdateFinetuneRequest = {
                name: requestParameters.name
            };
            const localVarAxiosArgs = await localVarAxiosParamCreator.update(requestParameters.id, requestParameters.projectId, updateFinetuneRequest, options);
            return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
        },
    }
};

/**
 * FinetunesApi - factory interface
 * @export
 */
export const FinetunesApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = FinetunesApiFp(configuration)
    return {
        /**
         * Trigger the fine-tuning process for a specific base model and data snapshot.
         * @summary Create
         * @param {FinetunesApiCreateRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        create(requestParameters: FinetunesApiCreateRequest, options?: AxiosRequestConfig): AxiosPromise<FinetuneResponse> {
            return localVarFp.create(requestParameters, options).then((request) => request(axios, basePath));
        },
        /**
         * Get a list of all fine-tuned models associated to a given project.
         * @summary List 
         * @param {FinetunesApiListAllForProjectRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listAllForProject(requestParameters: FinetunesApiListAllForProjectRequest, options?: AxiosRequestConfig): AxiosPromise<Array<FinetuneResponse>> {
            return localVarFp.listAllForProject(requestParameters, options).then((request) => request(axios, basePath));
        },
        /**
         * Checks data for errors and generates finetune data summary.  Does not actually trigger the finetuning process or persist the data.
         * @summary Summarize
         * @param {FinetunesApiSummaryRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        summary(requestParameters: FinetunesApiSummaryRequest, options?: AxiosRequestConfig): AxiosPromise<FinetuneDataSummary> {
            return localVarFp.summary(requestParameters, options).then((request) => request(axios, basePath));
        },
        /**
         * Update user-specified attributes of the specified finetuned models.
         * @summary Update
         * @param {FinetunesApiUpdateRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        update(requestParameters: FinetunesApiUpdateRequest, options?: AxiosRequestConfig): AxiosPromise<FinetuneResponse> {
            return localVarFp.update(requestParameters, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * Request parameters for create operation in FinetunesApi.
 * @export
 * @interface FinetunesApiCreateRequest
 */
export type FinetunesApiCreateRequest = {
    
    /**
    * 
    * @type {string}
    * @memberof FinetunesApiCreate
    */
    readonly projectId: string
    
} & FinetuneRequest

/**
 * Request parameters for listAllForProject operation in FinetunesApi.
 * @export
 * @interface FinetunesApiListAllForProjectRequest
 */
export type FinetunesApiListAllForProjectRequest = {
    
    /**
    * 
    * @type {string}
    * @memberof FinetunesApiListAllForProject
    */
    readonly projectId: string
    
}

/**
 * Request parameters for summary operation in FinetunesApi.
 * @export
 * @interface FinetunesApiSummaryRequest
 */
export type FinetunesApiSummaryRequest = {
    
    /**
    * 
    * @type {string}
    * @memberof FinetunesApiSummary
    */
    readonly projectId: string
    
} & FinetuneRequest

/**
 * Request parameters for update operation in FinetunesApi.
 * @export
 * @interface FinetunesApiUpdateRequest
 */
export type FinetunesApiUpdateRequest = {
    
    /**
    * 
    * @type {string}
    * @memberof FinetunesApiUpdate
    */
    readonly id: string
    
    /**
    * 
    * @type {string}
    * @memberof FinetunesApiUpdate
    */
    readonly projectId: string
    
} & UpdateFinetuneRequest

/**
 * FinetunesApiGenerated - object-oriented interface
 * @export
 * @class FinetunesApiGenerated
 * @extends {BaseAPI}
 */
export class FinetunesApiGenerated extends BaseAPI {
    /**
     * Trigger the fine-tuning process for a specific base model and data snapshot.
     * @summary Create
     * @param {FinetunesApiCreateRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof FinetunesApiGenerated
     */
    public create(requestParameters: FinetunesApiCreateRequest, options?: AxiosRequestConfig) {
        return FinetunesApiFp(this.configuration).create(requestParameters, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Get a list of all fine-tuned models associated to a given project.
     * @summary List 
     * @param {FinetunesApiListAllForProjectRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof FinetunesApiGenerated
     */
    public listAllForProject(requestParameters: FinetunesApiListAllForProjectRequest, options?: AxiosRequestConfig) {
        return FinetunesApiFp(this.configuration).listAllForProject(requestParameters, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Checks data for errors and generates finetune data summary.  Does not actually trigger the finetuning process or persist the data.
     * @summary Summarize
     * @param {FinetunesApiSummaryRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof FinetunesApiGenerated
     */
    public summary(requestParameters: FinetunesApiSummaryRequest, options?: AxiosRequestConfig) {
        return FinetunesApiFp(this.configuration).summary(requestParameters, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Update user-specified attributes of the specified finetuned models.
     * @summary Update
     * @param {FinetunesApiUpdateRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof FinetunesApiGenerated
     */
    public update(requestParameters: FinetunesApiUpdateRequest, options?: AxiosRequestConfig) {
        return FinetunesApiFp(this.configuration).update(requestParameters, options).then((request) => request(this.axios, this.basePath));
    }
}
